Skip to content

Fix lazy bindToMany relation caching to match eager-loaded collections#285

Merged
techmahedy merged 1 commit into
doppar:3.xfrom
techmahedy:techmahedy-3.x
May 21, 2026
Merged

Fix lazy bindToMany relation caching to match eager-loaded collections#285
techmahedy merged 1 commit into
doppar:3.xfrom
techmahedy:techmahedy-3.x

Conversation

@techmahedy
Copy link
Copy Markdown
Member

This fixes an inconsistency in lazy bindToMany loading where the first property access returned a collection of related models, but the cached relation on subsequent access was stored as a grouped raw array keyed by the pivot foreign key.

With this change, lazy bindToMany now caches the relation as a proper Collection, matching the eager-loading path. Repeated access to many-to-many relations now stays consistent and related items continue to include pivot data as expected.

Also adds regression coverage for repeated lazy bindToMany access and updates the related query test expectations to match the corrected collection behavior.

@techmahedy techmahedy added the bug Something isn't working label May 21, 2026
@techmahedy techmahedy merged commit 6e156b4 into doppar:3.x May 21, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant